# -*- coding: utf-8 -*-
"""
author:码同学 极光
date:2023-02-04
desc: 
sample: 
"""
import os

import pytest
import requests

from util import getcsv_listdict, get_project_path

host = 'http://82.156.74.26:9088'  # 静态 类变量

@pytest.fixture()
def login2(request):
    dict = request.param
    url = host + "/pinter/bank/api/login2"
    data = {
        'userName': dict['username'],
        'password': dict['pwd'],
    }
    response = requests.post(url, data=data)
    print(f"是否成功{response.status_code}")
    print(f"返回结果{response.text}")
    # 提取处理
    json = response.json()
    token = json["data"]
    dict['token']=token
    return dict


test_data = getcsv_listdict(os.path.join(get_project_path(), "files", "user.csv"))

@pytest.mark.parametrize("login2", test_data, indirect=True)
def test_name(login2):
    print(f" 测试用例的登录账号是：{login2} ")